﻿using System;
using System.Collections;
using System.Web.Services;
using System.Web.UI.WebControls;

/// <summary>
/// Summary description for AutoComplete
/// </summary>
[WebService(Namespace = "SearchAutocomplete")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]

public class AutoCompleteWebServices
{
    [WebMethod]
    public string[] SearchText(string prefixText)
    {
        ManageDatabase data = new ManageDatabase();
        ListItemCollection result = new ListItemCollection();

        string[] items = new string[result.Count];
        int i = 0;
        foreach (ListItem item in result)
        {
            items.SetValue(item.Text, i);
            i++;
        }
        return items;
    }
}